import { ColumnProps } from '~/library/components/ProTable/interface'
import { getSupplierAPI } from '~/src/api/goods'
import { Procure } from '~/src/api/interface/procure'
import { getLastQuarterDays } from '~/src/utils/date'
import { formatDate } from '~/src/utils/date-formatter'
import { warehouseStatus } from '~/src/utils/serviceDict'

export const columns: Array<ColumnProps<Procure.Rejection>> = [
  { type: 'selection', width: 60 },
  { type: 'index', label: '序号', width: 60 },
  {
    sortable: true,
    prop: 'date',
    label: '退货日期',
    minWidth: 150,
    search: {
      defaultValue: [formatDate(-getLastQuarterDays(), 'start', 'yyyy-MM-dd'), formatDate(0, 'end', 'yyyy-MM-dd')],
      el: 'date-picker',
      key: 'timeValue',
      order: 1,
      props: {
        type: 'datetimerange',
        format: 'YYYY-MM-DD',
        valueFormat: 'YYYY-MM-DD',
      },
    },
  },
  { sortable: true, prop: 'orderNo', label: '单据编号', minWidth: 180, search: { el: 'input' } },
  {
    sortable: true,
    prop: 'supplierName',
    label: '供应商',
    minWidth: 120,
    enum: () => getSupplierAPI({ pageNum: 1, pageSize: 9999 }),
    fieldNames: { label: 'name', value: 'id' },
    isFilterEnum: false,
    search: { el: 'select', key: 'supplierId' },
  },
  {
    sortable: true,
    prop: 'checkFlag',
    label: '单据状态',
    minWidth: 120,
    enum: warehouseStatus,
    align: 'center',
    search: { el: 'select', key: 'checkFlag' },
  },
  { sortable: true, prop: 'itemCount', label: '物品（项）', minWidth: 110 },
  { sortable: true, prop: 'amount', label: '金额', minWidth: 110 },
  {
    sortable: true,
    prop: 'sourceNo',
    label: '关联单号',
    minWidth: 140,
    align: 'center',
  },
  {
    sortable: true,
    prop: 'createTime',
    label: '创建时间',
    minWidth: 160,
  },

  { sortable: true, prop: 'remark', label: '备注', minWidth: 170, search: { el: 'input' } },
  { prop: 'operation', label: '操作', width: 220, fixed: 'right' },
]
